#include <iostream>
#include <pthread.h>

namespace MutexNamespace
{

    class Mutex
    {
    public:
        Mutex()
        {
            pthread_mutex_init(&_mutex, nullptr);
        }

        void Lock()
        {
            int n = pthread_mutex_lock(&_mutex);
            (void)n;
        }

        void UnLock()
        {
            int n = pthread_mutex_unlock(&_mutex);
            (void)n;
        }

        pthread_mutex_t &Getmutex()
        {
            return _mutex;
        }

        ~Mutex()
        {
            pthread_mutex_destroy(&_mutex);
        }

    private:
        pthread_mutex_t _mutex;
    };

    class LockGuard
    {
    public:
        LockGuard(Mutex &mutex)
            : _mx(mutex)
        {
            _mx.Lock();
        }

        ~LockGuard()
        {
            _mx.UnLock();
        }

    private:
        Mutex &_mx;
    };

}